Skip to content

Fix potential integer overflow in sdsMakeRoomFor#186

Open
Luobao0318 wants to merge 1 commit intoantirez:masterfrom
Luobao0318:fix-integer-overflow
Open

Fix potential integer overflow in sdsMakeRoomFor#186
Luobao0318 wants to merge 1 commit intoantirez:masterfrom
Luobao0318:fix-integer-overflow

Conversation

@Luobao0318
Copy link
Copy Markdown

Replaced the assert() based overflow check in sdsMakeRoomFor with a mandatory runtime check.

The original assertion is stripped out in production builds when NDEBUG is defined, leaving the code vulnerable to potential integer overflows and subsequent heap corruption. This patch keeps the overflow check active in all build configurations and returns NULL when a size_t overflow is detected.

Using a runtime check instead of assert to prevent heap overflow when NDEBUG is defined.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant